From d5e99da7b689d64a893264b0dc9710f4bf06d59c Mon Sep 17 00:00:00 2001 From: addshore Date: Tue, 15 Mar 2016 01:12:29 +0000 Subject: [PATCH] Use WatchedItemStore::removeWatch in SpecialEditWatchlist Bug: T129481 Change-Id: I12bf46244532195ba19516ba571a1728bd365db9 --- includes/specials/SpecialEditWatchlist.php | 34 ++++------------------ 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/includes/specials/SpecialEditWatchlist.php b/includes/specials/SpecialEditWatchlist.php index 1a9d09662b..e76988dd7d 100644 --- a/includes/specials/SpecialEditWatchlist.php +++ b/includes/specials/SpecialEditWatchlist.php @@ -413,22 +413,15 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { return; // nothing to do } - $dbw = wfGetDB( DB_MASTER ); $user = $this->getUser(); + $store = WatchedItemStore::getDefaultInstance(); foreach ( $this->badItems as $row ) { list( $title, $namespace, $dbKey ) = $row; $action = $title ? 'cleaning up' : 'deleting'; wfDebug( "User {$user->getName()} has broken watchlist item ns($namespace):$dbKey, $action.\n" ); - $dbw->delete( 'watchlist', - [ - 'wl_user' => $user->getId(), - 'wl_namespace' => $namespace, - 'wl_title' => $dbKey, - ], - __METHOD__ - ); + $store->removeWatch( $user, new TitleValue( $namespace, $dbKey ) ); // Can't just do an UPDATE instead of DELETE/INSERT due to unique index if ( $title ) { @@ -494,7 +487,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { * @param array $titles Array of strings, or Title objects */ private function unwatchTitles( $titles ) { - $dbw = wfGetDB( DB_MASTER ); + $store = WatchedItemStore::getDefaultInstance(); foreach ( $titles as $title ) { if ( !$title instanceof Title ) { @@ -502,25 +495,8 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { } if ( $title instanceof Title ) { - $dbw->delete( - 'watchlist', - [ - 'wl_user' => $this->getUser()->getId(), - 'wl_namespace' => MWNamespace::getSubject( $title->getNamespace() ), - 'wl_title' => $title->getDBkey(), - ], - __METHOD__ - ); - - $dbw->delete( - 'watchlist', - [ - 'wl_user' => $this->getUser()->getId(), - 'wl_namespace' => MWNamespace::getTalk( $title->getNamespace() ), - 'wl_title' => $title->getDBkey(), - ], - __METHOD__ - ); + $store->removeWatch( $this->getUser(), $title->getSubjectPage() ); + $store->removeWatch( $this->getUser(), $title->getTalkPage() ); $page = WikiPage::factory( $title ); Hooks::run( 'UnwatchArticleComplete', [ $this->getUser(), &$page ] ); -- 2.20.1